home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2 / DJLSR200.ZIP / src / libc / ansi / stdio / fopen.txh < prev    next >
Encoding:
Text File  |  1995-07-10  |  1.7 KB  |  73 lines

  1. @node fopen, stdio
  2. @subheading Syntax
  3.  
  4. @example
  5. #include <stdio.h>
  6. FILE *fopen(const char *filename, const char *mode);
  7. @end example
  8.  
  9. @subheading Description
  10.  
  11. This function opens a stream corresponding to the named @var{filename}
  12. with the given @var{mode}.  The mode can be one of the following:
  13.  
  14. @table @code
  15.  
  16. @item r
  17.  
  18. Open an existing file for reading.
  19.  
  20. @item w
  21.  
  22. Create a new file (or truncate an existing file) and open it for
  23. writing. 
  24.  
  25. @item a
  26.  
  27. Open an existing file (or create a new one) for writing.  The file
  28. pointer is positioned to the end of the file before every write. 
  29.  
  30. @end table
  31.  
  32. Followed by any of these characters:
  33.  
  34. @table @code
  35.  
  36. @item b
  37.  
  38. Force the file to be open in binary mode instead of the default mode.
  39.  
  40. @item t
  41.  
  42. Force the file to be open in text mode instead of the default mode.
  43.  
  44. @item +
  45.  
  46. Open the file as with @code{O_RDWR} so that both reads and writes
  47. can be done to the same file.
  48.  
  49. @end table
  50.  
  51. If the file is open for both reading and writing, you must call
  52. @code{fflush}, @code{fseek}, or @code{rewind} before switching from read
  53. to write or from write to read. 
  54.  
  55. The open file is set to line buffered if the underlying object is a
  56. device (stdin, stdout, etc), or is fully buffered if the underlying
  57. object is a disk file (data.c, etc).
  58.  
  59. If @code{b} or @code{t} is not specified in @var{mode}, the file type is
  60. chosen by the value of @code{fmode} (@pxref{_fmode}). 
  61.  
  62. @subheading Return Value
  63.  
  64. A pointer to the @code{FILE} object, or @code{NULL} if there was an
  65. error. 
  66.  
  67. @subheading Example
  68.  
  69. @example
  70. FILE *f = fopen("foo", "rb+"); /* open existing file for read/write, binary mode */
  71. @end example
  72.  
  73.